<?php
require __DIR__ . '/../vendor/autoload.php';

use Bostin\Translator\Translator;


$sourceText = '输入你想翻译的内容';
$source = 'zh';
$target = 'en';

$config = [
    // 百度
    'appid' => '',
    'secret' => '',

    // 腾讯
    'secretId' => '',
    'secretKey' => '',


    // 有道
    'appKey' => '',
    'secret' => '',


    // 译云
    'app_kid' => '',
    'app_key' => '',


    // Google
    'projectId' => '',


    // Microsoft
    'Ocp-Apim-Subscription-Key' => '',
    // 上面的 "Ocp-Apim-Subscription-Key" 与下面的 "Ocp-Api-Subscription-Key and Ocp-Apim-Subscription-Region" 二选一
    //'Ocp-Api-Subscription-Key' => '',
    //'Ocp-Apim-Subscription-Region' => '',
];

// 百度
$translator = new Translator(Translator::PROVIDER_BAIDU, $config);
$targetText = $translator->text($sourceText, $source, $target);
var_dump('百度', $targetText);

// 腾讯
$translator = new Translator(Translator::PROVIDER_TENCENT, $config);
$targetText = $translator->text($sourceText, $source, $target);
var_dump('腾讯', $targetText);

// 有道
$translator = new Translator(Translator::PROVIDER_YOUDAO, $config);
$targetText = $translator->text($sourceText, $source, $target);
var_dump('有道', $targetText);

// 译云
$translator = new Translator(Translator::PROVIDER_YEEKIT, $config);
$targetText = $translator->text($sourceText, $source, $target);
var_dump('译云', $targetText);

// Google
$translator = new Translator(Translator::PROVIDER_GOOGLE, $config);
$targetText = $translator->text($sourceText, $source, $target);
var_dump('Google', $targetText);

// Microsoft
$translator = new Translator(Translator::PROVIDER_MICROSOFT, $config);
$targetText = $translator->text($sourceText, $source, $target);
var_dump('Microsoft', $targetText);

